package j01xiancheng;

class MyThread extends Thread{
    //1-10
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(i+1);
        }
    }

    public MyThread() {
    }

    public MyThread(String name) {
        super(name);
    }
}
/*
线程特点：
a刚拿到使用权，
 */
public class J1 {
    public static void main(String[] args) {
        MyThread my1 = new MyThread();
//        my1.run();
        //启动线程
        my1.start();
        //线程
//        System.out.println("main end");
        for (int i = 0; i < 100; i++) {
            System.out.println("main-"+i);
        }
    }
}

class J2Name{
    public static void main(String[] args) {
        Thread t1 = new MyThread(){
            @Override
            public void run() {
                System.out.println(1111);
            }
        };
        Thread t2 = new MyThread(){
            @Override
            public void run() {
                System.out.println(1111);
            }
        };
        //
        System.out.println(t1);
        System.out.println(t1.getName());
        System.out.println(t2.getName());
        t2.setName("鲁西南");
        System.out.println(t2.getName());

        MyThread t3 = new MyThread("三个诸葛亮");
        System.out.println("t3 = " + t3.getName());

    }
}